package com.effvi.web.api.taobao;

import java.util.List;

import com.taobao.api.ApiException;
import com.taobao.api.TaobaoClient;
import com.taobao.api.domain.TaobaokeItem;
import com.taobao.api.domain.User;
import com.taobao.api.request.TaobaokeItemsGetRequest;
import com.taobao.api.request.UsersGetRequest;
import com.taobao.api.response.TaobaokeItemsGetResponse;
import com.taobao.api.response.UsersGetResponse;

public class App {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		TaobaoClient client = Client.getDefaultTaobaoClient();
//		UsersGetRequest get = new UsersGetRequest();
//		get.setNicks("ducter2");
//		get.setFields("user_id");
//		UsersGetResponse rsp = null;
//		try {
//			rsp = client.execute(get);
//		} catch (ApiException e) {
//			e.printStackTrace();
//		}
//		User u = rsp.getUsers().get(0);
//		System.out.println("Uid: "+u.getUid());
//		System.out.println("UserId: "+u.getUserId());
		
		TaobaokeItemsGetRequest items = new TaobaokeItemsGetRequest();
		items.setFields("num_iid,title,nick,pic_url,price,click_url,commission,commission_rate,commission_num,commission_volume,shop_click_url,seller_credit_score,item_location,volume");
		items.setStartCommissionRate("2000");
		items.setEndCommissionRate("9900");
		items.setCid(50010850L);
		items.setNick("ducter2");
		items.setPid(34473891L);
		TaobaokeItemsGetResponse rsp = null;
		try {
			rsp = client.execute(items);
		} catch (ApiException e) {
			e.printStackTrace();
		}
		List<TaobaokeItem> item = rsp.getTaobaokeItems();
		for(TaobaokeItem get:item){
			System.out.println(get.getClickUrl());
		}
		System.out.println("本次返回结果: " + item.size() + " 条!");
		System.out.println("查询到结果: " + rsp.getTotalResults() + " 条!");
	}

}
